<template>
  <div class="app-wrapper">
        <div class="lm-swipe">
            <router-link class="tag" to="/invitation"><i class="icon icon-share"></i> 邀请卡</router-link>
            <swiper>
　　            <swiper-slide><img :src="channel.cover" /></swiper-slide>
            </swiper>
        </div>
        <div class="home-desc clearfix mb15">
            <h3 class="pull-left">{{channel.name}}</h3>
            <span class="subtitle-more pull-right">已更新{{channel.live_num}}个直播</span>
        </div>
        <div class="home-main">
            <div class="tab-header text-center">
                <div class="tab-header-item"
                    :class="{'active': activeTab === 'topic'}"
                    @click="activeTab = 'topic'"
                ><span>话题列表</span></div>
                <div class="tab-header-item"
                    :class="{'active': activeTab === 'channel'}"
                    @click="activeTab = 'channel'"
                ><span>频道简介</span></div>
            </div>
            <div class="tab-body">
                <div class="tab-body-item topic-list" v-show="activeTab === 'topic'">
                    <ul>
                        <!-- <router-link tag="li" to="/live"
                            class="topic-list-item"
                            v-for="item in lives"
                            :key="item.id" >
                        > -->
                        <router-link
                            class="topic-list-item"
                            v-for="item in lives"
                            :key="item.id"
                            :to="{name:'live', params: {id:item.id}}"
                            tag="li"
                        >
                            <div class="topic-list-thumb relative">
                                <span class="orange">{{item.live_status_text}}</span>
                                <img :src="item.cover" alt="">
                            </div>
                            <div class="list-body flex-item">
                                <h4 class="list-body-head">{{item.title}}</h4>
                                <p class="list-body-subinfo"><span>{{item.type_text}}</span><span class="div-line">|</span><time>{{item.start_at}}</time></p>
                                <p class="topic-list-body-count">{{item.fic_num}}人次观看<span><i class="icon icon-msg"></i></span></p>
                            </div>
                        </router-link>

                    </ul>
                </div>
                <div class="tab-body-item channel-list" v-show="activeTab === 'channel'">
                  <template v-for="(intro_content,index) in intro">
                    <h3 class="title">{{intro_content.name}}</h3>
                    <div v-html="intro_content.content"></div>
                  </template>

                    <ul>
                        <li class="channel-list-item">
                            <div class="media clearfix">
                                <div class="media-object pull-left">
                                    <img :src="siteinfo.live_logo" />
                                </div>
                                <div class="media-body">
                                    <h4 class="media-heading">{{siteinfo.live_name}}</h4>
                                </div>
                                <span class="media-option disabled">已关注</span>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="button" @click="showNavbar = true"></div>
        <div class="action-sheet text-center" :class="{'show': showNavbar}">
            <ul class="action-list">
                <router-link tag="li" to="/">
                    <div>
                        <span><i class="img-icon img-icon-home"></i><p>主页</p></span>
                    </div>
                </router-link>
                <li>
                    <div @click="showPromptDialog">
                        <span><i class="img-icon img-icon-zixun"></i><p>咨询</p></span>
                    </div>
                </li>
                <router-link tag="li" to="/mine">
                    <div>
                        <span><i class="img-icon img-icon-user"></i><p>个人中心</p></span>
                    </div>
                </router-link>
            </ul>
            <button class="button-block" @click="showNavbar = false">取消</button>
        </div>


        <div class="dialog-prompt text-center" v-if="promptDialogShow">
            <div class="dialog-title">咨询</div>
            <div class="dialog-body">
                <input type="text" placeholder="" class="input-text" v-model="promptContent">
            </div>
            <div class="dialog-options">
                <button type="button" class="buton-cancel" @click.stop="hidePromptDialog">取消</button><button type="button" class="buton-true" @click.stop="submitPromptContent">确定</button>
            </div>
        </div>


  </div>
</template>

<script>
import TopicItem from '@/components/TopicItem';
import 'swiper/dist/css/swiper.css';
import { swiper, swiperSlide } from 'vue-awesome-swiper';
import {getIndexInfomation, getChannelList} from '@/api';
export default {
  components: {
    swiper,
    swiperSlide,
    TopicItem
  },
  props: {},
  data() {
    return {
        promptDialogShow: false,
        promptContent: '', // 咨询内容
        activeTab: 'topic',
        showNavbar: false,
        channel: {
            cover: '',
            id: '',
            live_num: '',
            intro: ''
        },
        lives:[],
        siteinfo:{},
        introLists: [
            {
                id: 1,
                name: '目睹直播平台',
                imgSrc: './img/home_intro_img.png',
                isFollow: true
            },
            {
                id: 2,
                name: '目睹直播平台2',
                imgSrc: './img/home_intro_img.png',
                isFollow: false
            },
            {
                id: 3,
                name: '目睹直播平台3',
                imgSrc: './img/home_intro_img.png',
                isFollow: true
            }
        ],
        swiperOption: {
            pagination: {
        　　　　el: '.swiper-pagination'
        　　}
        }
    };
  },
  computed: {},
  methods: {
      showPromptDialog(){
        this.promptDialogShow = true;
        this.$store.dispatch('setMaskerDisplay', true);
      },
      hidePromptDialog(){
        this.promptDialogShow = false;
        this.$store.dispatch('setMaskerDisplay', false);
      },
      submitPromptContent(){

        console.log(this.promptContent)
        this.hidePromptDialog();
      },
      switchFollowStatus(item){
          setTimeout(()=>{
              item.isFollow = !item.isFollow;
          }, 1500);
      }
  },
  created() {
      getChannelList().then((response)=>{
          this.lives = response.data.lives;
          this.channel = response.data.channel;
          this.intro = response.data.intro;
          this.siteinfo = response.data.siteinfo;
      });
  },
  mounted() {}
};
</script>
<style lang="scss" scoped>
@import '@/assets/config.scss';
.action-sheet {
    position: fixed;
    width: 100%;
    bottom: 0;
    left: 0;
    font-size: 24px;
    color: #333;
    background-color: #eceded;
    transition: all .3s ease-in-out;
    transform: translate3d(0, 100%, 0);
    z-index: 10;
    &.show {
         transform: translate3d(0, 0, 0);
    }
    .action-list {
        display: flex;
        height: 128px;

        margin-bottom: 14px;
        background: #fff;
        > li {
            flex: 1;
            height: 128px;
        }

        div {
            display: flex;
            height: 100%;
            align-items: center;
            justify-content:center;
        }
        span{display: inline-block;}
        i {
            display: inline-block;
            width: 50px;
            height: 50px;
        }
        p { line-height: 2; }
    }
    .button-block{
        width: 100%;
        height: 90px;
        line-height: 90px;
        font-size: 30px;
        text-align: center;
        background-color: #fff;
    }
}

.lm-swipe {
    height: 350px;
    overflow: hidden;
    position: relative;
    .tag {
        padding: 0 10px;
        position: absolute;
        top: 0;
        right: 0;
        font-size: 24px;
        color: #fff;
        line-height: 2;
        border-radius: 0 0 0 12px;
        background: linear-gradient(#318bff, #103ee7);
        z-index: 5;
        .icon {
            font-size: 32px;
            vertical-align: middle;
            position: relative;
            top: 2px;
        }
    }

    .swiper-slide img {
        width: 100%;
        height: 350px;
    }

    .swiper-pagination-bullet {
        width: 20px;
        height: 20px;
    }
}

.home-desc {
    height: 100px;
    padding: 0 35px;
    line-height: 100px;
    background-color: $bg-white;

    > h3 {
        color: $title-color;
        font-size: 34px;
    }

    .subtitle-more {
        font-size: 26px;
        color: $desc-color;
    }
}

.home-main {
    background-color: $bg-white;
}


.topic-list-item {
  display: flex;
  padding: 25px 35px;
  align-items: center;
  position: relative;
  &:after {
    content: '';
    height: 2px;
    position: absolute;
    left: 35px;
    right: 35px;
    bottom: 0;
    background-color: #f0f0f0;
  }

   .topic-list-thumb {
    width: 40%;
    margin-right: 20px;
    position: relative;
    > span {
      position: absolute;
      top: 10px;
      left: 10px;
      padding: 6px 7px 5px;
      font-size: 24px;
      color: #fff;
      line-height: 26px;
      border-radius: 2px;
      &.blue{
        background: #1549eb;
      }

      &.orange {
        background: #fcba2e;
      }
    }
  }
}


.tab-header {
    display: flex;
    align-items: center;
    position: relative;
    &:after {
        content: '';
        position: absolute;
        width: 2px;
        height: 28px;
        background-color: #ddd;
        left: 50%;
        top: 50%;
        transform: translate3d(-50%, -50%, 0)
    }
}

.tab-header-item {
    flex: 1;
    font-size: 30px;
    color: #333;

    span {
        display: inline-block;
        padding: 30px 0 36px;
        position: relative;
    }

    &.active span {

        color: #1549eb;
        &:after{
            width: 100%;
            position: absolute;
            left: 0;
            bottom: 0;
            content: '';
            height: 4px;
            background-color: #1549eb;
        }
    }

}

    .list-body-head {
        font-size: 28px;
        line-height: 36px;
        color: $title-color;
    }

    .topic-list-body-count, .list-body-subinfo {
        font-size: 24px;
        line-height: 2;
        color: #888;
    }

    .div-line{
        margin: 0 20px 0 24px;
    }

.channel-list {
    padding: 0 35px;
    .title {
        height: 90px;
        border-bottom: 1px solid #f0f0f0;
        margin-bottom: 10px;
        line-height: 90px;
        font-size: 30px;
        color: #2a2a2a;
    }
}
.channel-list-item {
    padding: 20px 0;
    position: relative;

    .media {
        display: flex;
        align-items: center;
    }
    .media-object{
        width: 80px;
        height: 80px;
        margin-right: 20px;
        img { vertical-align: top; }
    }
    .media-body {
        overflow: hidden;
    }
    .media-heading {
        font-size: 28px;
        color: #333;
    }

    .media-option {
        width: 110px;
        height: 54px;
        border: 2px solid #1549eb;
        position: absolute;
        right: 0;
        top: 50%;
        font-size: 24px;
        color: #1549eb;
        text-align: center;
        line-height: 54px;
        border-radius: 27px;
        transform: translateY(-50%);
        &.disabled {
            color: #b6b6b6;
            border: 2px solid #b6b6b6;
        }
    }
}

.button {
    position: fixed;
    width: 100px;
    height: 100px;
    border-radius: 100%;
    bottom: 94px;
    right: 35px;
    background: linear-gradient(#103ee7, #318bff);
    transform: rotate(111deg);
    z-index: 5;
    &:after, &:before {
        content: '';
        background: $bg-white;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate3d(-50%, -50%, 0) rotate(-111deg);
        border-radius: 2px;
    }

    &:after {
        width: 4px;
        height: 40px;

    }

    &:before {
        width: 40px;
        height: 4px;
    }
}


.dialog-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 560px;
    height: 300px;
    padding-top: 20px;
    font-size: 30px;
    color: #999;
    background-color: #fff;
    border-radius: 16px;
    transform: translate3d(-50%, -50%, 0);
    z-index: 200;
    .dialog-title {
        line-height: 2;
        color: #333;
    }
    .dialog-body {
        padding:  30px 0;
    }

    .input-text {
        width: 85%;
        height: 80px;
        padding: 0 20px;
        margin-right: 15px;
        border: 1px solid #ccc;
        line-height: 74px;;
        border-radius: 6px;
    }

    .dialog-options {
        height: 80px;
        line-height: 80px;
        position: relative;

        &:before{
            content: '';
            display: block;
            width: 100%;
            height: 2px;
            top: 0;
            background: #ccc;
        }
        &:after {
            content: '';
            display: block;
            height: 80px;
            width: 2px;
            background: #ccc;
            position: absolute;
            top: 0;
            left: 50%;
            margin-left: -1px;
        }

        button {
            width: 50%;
            background-color: transparent;
        }

        .buton-true { color: #1549eb; }
    }

}
</style>
